package cn.cheln.support.images;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.Matrix;
import android.graphics.drawable.BitmapDrawable;
import android.util.DisplayMetrics;
import cn.cheln.explorer.beans.AppInfoData;
import cn.cheln.explorer.beans.FileInfo;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

public class Utillocal
{
  static final String PATH_AssetManager = "shortcut.content.res.AssetManager";
  static final String PATH_PackageParser = "shortcut.content.pm.PackageParser";
  static Class<?> assetMagCls;
  static Method assetMag_addAssetPathMtd;
  static BitmapFactory.Options options = new BitmapFactory.Options();
  static Class<?> pkgParserCls;
  static Constructor<?> pkgParserCt;
  static Method pkgParser_parsePackageMtd;
  static Class<?>[] resContructParas;
  static Constructor<Resources> resCt;
  public static int thumbnailHeight;
  public static int thumbnailWidth = 42;

  static
  {
    thumbnailHeight = 42;
    try
    {
      pkgParserCls = Class.forName("shortcut.content.pm.PackageParser");
      assetMagCls = Class.forName("shortcut.content.res.AssetManager");
      pkgParserCt = pkgParserCls.getConstructor(new Class[] { String.class });
      Class localClass = pkgParserCls;
      Class[] arrayOfClass = new Class[4];
      arrayOfClass[0] = File.class;
      arrayOfClass[1] = String.class;
      arrayOfClass[2] = DisplayMetrics.class;
      arrayOfClass[3] = Integer.TYPE;
      pkgParser_parsePackageMtd = localClass.getDeclaredMethod("parsePackage", arrayOfClass);
      assetMag_addAssetPathMtd = assetMagCls.getDeclaredMethod("addAssetPath", new Class[] { String.class });
      return;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }

  // ERROR //
  public static void compressBitmapToFile(Context paramContext, String paramString, Bitmap paramBitmap)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_3
    //   2: new 95	java/io/FileOutputStream
    //   5: dup
    //   6: aload_1
    //   7: invokespecial 98	java/io/FileOutputStream:<init>	(Ljava/lang/String;)V
    //   10: astore 4
    //   12: aload_2
    //   13: getstatic 104	android/graphics/Bitmap$CompressFormat:PNG	Landroid/graphics/Bitmap$CompressFormat;
    //   16: iconst_0
    //   17: aload 4
    //   19: invokevirtual 110	android/graphics/Bitmap:compress	(Landroid/graphics/Bitmap$CompressFormat;ILjava/io/OutputStream;)Z
    //   22: pop
    //   23: aload 4
    //   25: ifnull +63 -> 88
    //   28: aload 4
    //   30: invokevirtual 113	java/io/FileOutputStream:close	()V
    //   33: return
    //   34: astore 5
    //   36: aload 5
    //   38: invokevirtual 88	java/lang/Exception:printStackTrace	()V
    //   41: aload_3
    //   42: ifnull -9 -> 33
    //   45: aload_3
    //   46: invokevirtual 113	java/io/FileOutputStream:close	()V
    //   49: return
    //   50: astore 8
    //   52: aload 8
    //   54: invokevirtual 114	java/io/IOException:printStackTrace	()V
    //   57: return
    //   58: astore 6
    //   60: aload_3
    //   61: ifnull +7 -> 68
    //   64: aload_3
    //   65: invokevirtual 113	java/io/FileOutputStream:close	()V
    //   68: aload 6
    //   70: athrow
    //   71: astore 7
    //   73: aload 7
    //   75: invokevirtual 114	java/io/IOException:printStackTrace	()V
    //   78: goto -10 -> 68
    //   81: astore 10
    //   83: aload 10
    //   85: invokevirtual 114	java/io/IOException:printStackTrace	()V
    //   88: return
    //   89: astore 6
    //   91: aload 4
    //   93: astore_3
    //   94: goto -34 -> 60
    //   97: astore 5
    //   99: aload 4
    //   101: astore_3
    //   102: goto -66 -> 36
    //
    // Exception table:
    //   from	to	target	type
    //   2	12	34	java/lang/Exception
    //   45	49	50	java/io/IOException
    //   2	12	58	finally
    //   36	41	58	finally
    //   64	68	71	java/io/IOException
    //   28	33	81	java/io/IOException
    //   12	23	89	finally
    //   12	23	97	java/lang/Exception
  }

  public static Bitmap getApkIcon(Context paramContext, FileInfo paramFileInfo)
  {
    AppInfoData localAppInfoData = getApkInfo(paramContext, paramFileInfo.getFile());
    if ((localAppInfoData == null) || (localAppInfoData.icon == null));
    for (Bitmap localBitmap = FileInfo.iconPackage; ; localBitmap = ((BitmapDrawable)localAppInfoData.icon).getBitmap())
      return scaleBitmap(localBitmap);
  }

  public static Bitmap getApkIcon(Context paramContext, String paramString)
  {
    return getApkIcon(paramContext, new FileInfo(new File(paramString), paramContext));
  }

  // ERROR //
  public static AppInfoData getApkInfo(Context paramContext, File paramFile)
  {
    // Byte code:
    //   0: getstatic 56	cn/cheln/support/images/Utillocal:assetMagCls	Ljava/lang/Class;
    //   3: invokevirtual 161	java/lang/Class:newInstance	()Ljava/lang/Object;
    //   6: astore_3
    //   7: iconst_1
    //   8: anewarray 4	java/lang/Object
    //   11: astore 4
    //   13: aload 4
    //   15: iconst_0
    //   16: aload_1
    //   17: invokevirtual 165	java/io/File:getPath	()Ljava/lang/String;
    //   20: aastore
    //   21: getstatic 64	cn/cheln/support/images/Utillocal:pkgParserCt	Ljava/lang/reflect/Constructor;
    //   24: aload 4
    //   26: invokevirtual 170	java/lang/reflect/Constructor:newInstance	([Ljava/lang/Object;)Ljava/lang/Object;
    //   29: astore 5
    //   31: new 68	android/util/DisplayMetrics
    //   34: dup
    //   35: invokespecial 171	android/util/DisplayMetrics:<init>	()V
    //   38: astore 6
    //   40: aload 6
    //   42: invokevirtual 174	android/util/DisplayMetrics:setToDefaults	()V
    //   45: iconst_4
    //   46: anewarray 4	java/lang/Object
    //   49: astore 7
    //   51: aload 7
    //   53: iconst_0
    //   54: aload_1
    //   55: aastore
    //   56: aload 7
    //   58: iconst_1
    //   59: aload_1
    //   60: invokevirtual 165	java/io/File:getPath	()Ljava/lang/String;
    //   63: aastore
    //   64: aload 7
    //   66: iconst_2
    //   67: aload 6
    //   69: aastore
    //   70: aload 7
    //   72: iconst_3
    //   73: iconst_0
    //   74: invokestatic 178	java/lang/Integer:valueOf	(I)Ljava/lang/Integer;
    //   77: aastore
    //   78: getstatic 81	cn/cheln/support/images/Utillocal:pkgParser_parsePackageMtd	Ljava/lang/reflect/Method;
    //   81: aload 5
    //   83: aload 7
    //   85: invokevirtual 184	java/lang/reflect/Method:invoke	(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
    //   88: astore 8
    //   90: aload 8
    //   92: ifnonnull +5 -> 97
    //   95: aconst_null
    //   96: areturn
    //   97: aload 8
    //   99: invokevirtual 188	java/lang/Object:getClass	()Ljava/lang/Class;
    //   102: ldc 190
    //   104: invokevirtual 194	java/lang/Class:getDeclaredField	(Ljava/lang/String;)Ljava/lang/reflect/Field;
    //   107: astore 9
    //   109: aload 9
    //   111: aload 8
    //   113: invokevirtual 200	java/lang/reflect/Field:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   116: ifnonnull +12 -> 128
    //   119: ldc 202
    //   121: ldc 204
    //   123: invokestatic 210	cn/cheln/support/log/Logs:i	(Ljava/lang/String;Ljava/lang/String;)V
    //   126: aconst_null
    //   127: areturn
    //   128: aload 9
    //   130: aload 8
    //   132: invokevirtual 200	java/lang/reflect/Field:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   135: checkcast 212	android/content/pm/ApplicationInfo
    //   138: astore 10
    //   140: getstatic 85	cn/cheln/support/images/Utillocal:assetMag_addAssetPathMtd	Ljava/lang/reflect/Method;
    //   143: astore 11
    //   145: iconst_1
    //   146: anewarray 4	java/lang/Object
    //   149: astore 12
    //   151: aload 12
    //   153: iconst_0
    //   154: aload_1
    //   155: invokevirtual 165	java/io/File:getPath	()Ljava/lang/String;
    //   158: aastore
    //   159: aload 11
    //   161: aload_3
    //   162: aload 12
    //   164: invokevirtual 184	java/lang/reflect/Method:invoke	(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
    //   167: pop
    //   168: aconst_null
    //   169: astore 14
    //   171: iconst_0
    //   172: ifne +62 -> 234
    //   175: aload_0
    //   176: invokevirtual 218	android/content/Context:getResources	()Landroid/content/res/Resources;
    //   179: astore 14
    //   181: iconst_3
    //   182: anewarray 48	java/lang/Class
    //   185: putstatic 220	cn/cheln/support/images/Utillocal:resContructParas	[Ljava/lang/Class;
    //   188: getstatic 220	cn/cheln/support/images/Utillocal:resContructParas	[Ljava/lang/Class;
    //   191: iconst_0
    //   192: aload_3
    //   193: invokevirtual 188	java/lang/Object:getClass	()Ljava/lang/Class;
    //   196: aastore
    //   197: getstatic 220	cn/cheln/support/images/Utillocal:resContructParas	[Ljava/lang/Class;
    //   200: iconst_1
    //   201: aload 14
    //   203: invokevirtual 226	android/content/res/Resources:getDisplayMetrics	()Landroid/util/DisplayMetrics;
    //   206: invokevirtual 188	java/lang/Object:getClass	()Ljava/lang/Class;
    //   209: aastore
    //   210: getstatic 220	cn/cheln/support/images/Utillocal:resContructParas	[Ljava/lang/Class;
    //   213: iconst_2
    //   214: aload 14
    //   216: invokevirtual 230	android/content/res/Resources:getConfiguration	()Landroid/content/res/Configuration;
    //   219: invokevirtual 188	java/lang/Object:getClass	()Ljava/lang/Class;
    //   222: aastore
    //   223: ldc 222
    //   225: getstatic 220	cn/cheln/support/images/Utillocal:resContructParas	[Ljava/lang/Class;
    //   228: invokevirtual 62	java/lang/Class:getConstructor	([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
    //   231: putstatic 232	cn/cheln/support/images/Utillocal:resCt	Ljava/lang/reflect/Constructor;
    //   234: iconst_3
    //   235: anewarray 4	java/lang/Object
    //   238: astore 16
    //   240: aload 16
    //   242: iconst_0
    //   243: aload_3
    //   244: aastore
    //   245: aload 16
    //   247: iconst_1
    //   248: aload 14
    //   250: invokevirtual 226	android/content/res/Resources:getDisplayMetrics	()Landroid/util/DisplayMetrics;
    //   253: aastore
    //   254: aload 16
    //   256: iconst_2
    //   257: aload 14
    //   259: invokevirtual 230	android/content/res/Resources:getConfiguration	()Landroid/content/res/Configuration;
    //   262: aastore
    //   263: getstatic 232	cn/cheln/support/images/Utillocal:resCt	Ljava/lang/reflect/Constructor;
    //   266: aload 16
    //   268: invokevirtual 170	java/lang/reflect/Constructor:newInstance	([Ljava/lang/Object;)Ljava/lang/Object;
    //   271: checkcast 222	android/content/res/Resources
    //   274: astore 17
    //   276: new 128	cn/cheln/explorer/beans/AppInfoData
    //   279: dup
    //   280: invokespecial 233	cn/cheln/explorer/beans/AppInfoData:<init>	()V
    //   283: astore 18
    //   285: aload 10
    //   287: ifnull +95 -> 382
    //   290: aload 10
    //   292: getfield 236	android/content/pm/ApplicationInfo:labelRes	I
    //   295: istore 19
    //   297: aconst_null
    //   298: astore 20
    //   300: iload 19
    //   302: ifeq +15 -> 317
    //   305: aload 17
    //   307: aload 10
    //   309: getfield 236	android/content/pm/ApplicationInfo:labelRes	I
    //   312: invokevirtual 240	android/content/res/Resources:getText	(I)Ljava/lang/CharSequence;
    //   315: astore 20
    //   317: aload 18
    //   319: aload 20
    //   321: invokeinterface 245 1 0
    //   326: putfield 248	cn/cheln/explorer/beans/AppInfoData:name	Ljava/lang/String;
    //   329: aload 10
    //   331: getfield 250	android/content/pm/ApplicationInfo:icon	I
    //   334: ifeq +51 -> 385
    //   337: aload 18
    //   339: aload 17
    //   341: aload 10
    //   343: getfield 250	android/content/pm/ApplicationInfo:icon	I
    //   346: invokevirtual 254	android/content/res/Resources:getDrawable	(I)Landroid/graphics/drawable/Drawable;
    //   349: invokevirtual 258	cn/cheln/explorer/beans/AppInfoData:setAppicon	(Landroid/graphics/drawable/Drawable;)V
    //   352: aload 18
    //   354: areturn
    //   355: astore_2
    //   356: aload_2
    //   357: invokevirtual 88	java/lang/Exception:printStackTrace	()V
    //   360: aconst_null
    //   361: areturn
    //   362: astore 21
    //   364: aload 21
    //   366: invokevirtual 259	java/lang/SecurityException:printStackTrace	()V
    //   369: goto -135 -> 234
    //   372: astore 15
    //   374: aload 15
    //   376: invokevirtual 260	java/lang/NoSuchMethodException:printStackTrace	()V
    //   379: goto -145 -> 234
    //   382: aconst_null
    //   383: astore 18
    //   385: aload 18
    //   387: areturn
    //
    // Exception table:
    //   from	to	target	type
    //   0	90	355	java/lang/Exception
    //   97	126	355	java/lang/Exception
    //   128	168	355	java/lang/Exception
    //   175	223	355	java/lang/Exception
    //   223	234	355	java/lang/Exception
    //   234	285	355	java/lang/Exception
    //   290	297	355	java/lang/Exception
    //   305	317	355	java/lang/Exception
    //   317	352	355	java/lang/Exception
    //   364	369	355	java/lang/Exception
    //   374	379	355	java/lang/Exception
    //   223	234	362	java/lang/SecurityException
    //   223	234	372	java/lang/NoSuchMethodException
  }

  public static String getExtFromFilename(String paramString)
  {
    int i = paramString.lastIndexOf(46);
    if (i != -1)
      return paramString.substring(i + 1, paramString.length());
    return "";
  }

  public static Bitmap getImage(String paramString, Bitmap paramBitmap, Context paramContext)
  {
    while (true)
    {
      int i;
      try
      {
        options.inJustDecodeBounds = true;
        options.outWidth = 160;
        options.outHeight = 232;
        options.inSampleSize = 2;
        BitmapFactory.decodeFile(paramString, options);
        if ((options.outWidth > 0) && (options.outHeight > 0))
        {
          i = Math.max(Math.max((-1 + options.outWidth + thumbnailWidth) / thumbnailWidth, (-1 + options.outHeight + thumbnailHeight) / thumbnailHeight), 1);
          if ((i <= 1) || ((i & i - 1) == 0))
          {
            options.inSampleSize = i;
            options.inJustDecodeBounds = false;
            Bitmap localBitmap = scaleBitmap(BitmapFactory.decodeFile(paramString, options));
            paramBitmap = localBitmap;
          }
        }
        return paramBitmap;
        i &= i - 1;
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
        return paramBitmap;
      }
      if ((i & i - 1) != 0)
        continue;
      i <<= 1;
    }
  }

  public static Bitmap scaleBitmap(Bitmap paramBitmap)
  {
    if (paramBitmap == null)
      return null;
    float f1 = thumbnailWidth / paramBitmap.getWidth();
    float f2 = thumbnailHeight / paramBitmap.getHeight();
    Matrix localMatrix = new Matrix();
    localMatrix.postScale(f1, f2);
    return Bitmap.createBitmap(paramBitmap, 0, 0, paramBitmap.getWidth(), paramBitmap.getHeight(), localMatrix, true);
  }
}

/* Location:           H:\360云盘\lewa_explorer_3.0\bin\FileApp_orig_dex2jar.jar
 * Qualified Name:     cn.cheln.support.images.Utillocal
 * JD-Core Version:    0.5.2
 */